'''
Created on 05.08.2011

@author: osman
'''

from collections import namedtuple 

class URI(namedtuple('URI', 'baseName objectName')):
    __slots__ = ()
    def __str__(self):
        from urllib.parse import urljoin
        baseName = self.baseName.strip()
        if baseName[-1] != '/': baseName += '/'
        objectName = self.objectName.strip()
        return urljoin(baseName, objectName)
    
if __name__ == "__main__":
    # short test:
    print("string: ", URI(" http://www.example.com ", " sample "))
    print("representation: ", repr(URI(" http://www.example.com ", " sample ")))